package IMIC.NGUYENVANTINH.ARRAY.EXCERCISE.EX06;

import java.util.Scanner;

public class Views {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		boolean flag = false;
		int n = 0;
		System.out.print("Nhap vao so sinh vien:");
		while (!flag) {
			try {
				n = sc.nextInt();
				flag = true;
			} catch (Exception e) {
				// Neu nhap sai thi phai nhap lai
				System.out.println("Ban phai nhap mot so nguyen...");
				sc.nextLine();
			}

		}
		// 1.Khoi tao doi tuong Student
		Student[] Arrstudent = new Student[n];
		// 2.Nhap vao thong tin sinh vien
		for (int i = 0; i < n; i++) {
			Student student = new Student();
			System.out.println("Nhap vao thong tin sinh vien thu " + i);
			System.out.print("RollNumber: ");
			sc = new Scanner(System.in);
			student.setRollNumber(sc.nextLine());
			System.out.print("FullName:");
			sc = new Scanner(System.in);
			student.setFullName(sc.nextLine());
			System.out.print("Mark:");
			sc = new Scanner(System.in);
			student.setMark(sc.nextDouble());
			Arrstudent[i] = student;
		}
		// 3.Khoi tao controllers
		Controllers controllers = new Controllers();
		// 4.Uy quyen thuc thi.
		Student[] sv = controllers.SortStudent(Arrstudent);
		System.out.println("Danh sach sinh vien sap xep theo diem la");
		for (int i = 0; i < sv.length; i++) {
			System.out.println("Rollnumber: " + sv[i].getRollNumber());
			System.out.println("Fullname: " + sv[i].getFullName());
			System.out.println("Mark: " + sv[i].getMark());
		}
		
	}

}
